<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <h2>结果是：{{result}}</h2>
    <h3>普通发送</h3>
    <button @click="send1">send1</button>
    <H3>传递参数</H3>
    <input v-model="message"/>
    <button @click="send2">send2</button>
    <h3>post传递参数</h3>
    <input v-model="message2"/>
    <button @click="send3">send3</button>
</div>
</body>
</html>
<script src="js/vue.min.js"></script>
<script src="js/axios.min.js"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                result: '',
                message: '',
                message2: ''
            }
        },
        methods: {
            send1() {
                let _this = this;
                axios.get('first/a')
                    .then((response) => {
                        _this.result = response.data;
                    })
            },
            send2() {
                let _this = this;
                axios.get('first/b', {
                    params: {
                        name: _this.message
                    }
                }).then((response) => {
                    _this.result = response.data;
                })
            },
            send3() {
                let _this = this;
                let data = new URLSearchParams();
                data.append("name", this.message2);
                axios({
                    method: 'post',
                    url: 'first/c',
                    data: data
                }).then((response) => {
                    _this.result = response.data;
                })
            }
        }
    })
</script>